home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / 80x0393.zip / POSXY.ASM < prev    next >
Assembly Source File  |  1993-06-20  |  1KB  |  44 lines

  1. ;
  2. ; Tasm module, Call from C
  3. ;
  4. ; pos_xy( int x, int y );
  5. ;
  6. ; Written by Craig Allsop, Public Domain.
  7. ; Assumes 16 colour mode, and screen width of 640 pixels.
  8. ;
  9. ; I only typed this from memory, but it should work.
  10. ;
  11.  
  12. ideal
  13. model   small,c
  14. codeseg
  15.  
  16. proc    pos_xy
  17.         arg     x:word, y:word
  18.  
  19.         mov     ax,[y]
  20.         mov     bl,80                   ; width of screen / 8 (bytes)
  21.         mul     bl
  22.         mov     bx,[x]
  23.         mov     cl,bl
  24.         shr     bx,3                    ; Convert to bytes from pixels
  25.         add     bx,ax
  26.         and     cl,7                    ; Keep pixel offset
  27.         mov     dx,3d4h
  28.         mov     ah,0ch
  29.         mov     al,bh
  30.         out     dx,al                   ; Set high order of address
  31.         mov     ah,0dh
  32.         mov     al,bl
  33.         out     dx,al                   ; Set low order of address
  34.         mov     dh,0dah
  35.         in      al,dx
  36.         mov     dh,0c0h
  37.         mov     al,33h                  ; Register 13 OR 20
  38.         out     dx,al
  39.         mov     al,cl
  40.         out     dx,al                   ; Output pixel panning offset
  41.         ret
  42. endp
  43. end pos_xy
  44.